package com.zhangx.study.demo.mybatis.service;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.stereotype.Component;

/**
 * @ClassName A
 * @Description TODO
 * @Author zhangx
 * @Date 2021/5/17 8:38
 **/
@Component
public class A implements BeanNameAware, BeanFactoryAware {

    private String beanName;
    /**
     * 设置bean factory中bean的名字
     * 在普通bean 属性填充后，在 初始化回调（InitializingBean#afterPropertiesSet()）
     * 或init-method之前
     *
     * @param name the name of the bean in the factory.
     *             Note that this name is the actual bean name used in the factory, which may
     *             differ from the originally specified name: in particular for inner bean
     *             names, the actual bean name might have been made unique through appending
     *             "#..." suffixes. Use the {@link BeanFactoryUtils#originalBeanName(String)}
     *             method to extract the original bean name (without suffix), if desired.
     */
    @Override
    public void setBeanName(String name) {
        this.beanName = name;
    }

    /**
     * 设置bean factory中bean的名字
     * 在普通bean 属性填充后，在 初始化回调（InitializingBean#afterPropertiesSet()）
     * 或init-method之前
     *
     * @param beanFactory owning BeanFactory (never {@code null}).
     *                    The bean can immediately call methods on the factory.
     * @throws BeansException in case of initialization errors
     * @see BeanInitializationException
     */
    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {

    }
}
